<template>
  <el-dialog title="提示" :visible.sync="visible" :width="width" top="5vh" append-to-body>
    <el-form>
      <el-form-item label="">
        <el-input
          v-model="inputValue"
          :placeholder="placeholderTips"
          clearable
        ></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="btnConfirm">确 定</el-button>
      <el-button @click="visible = false">取 消</el-button>
    </div>
  </el-dialog>
</template>


<script>

  export default {
    props:{
      inputPlaceholder: {
        type: String
      },
      width:{
        type: String
      }
    },
    data() {
      return {
        inputValue: '',
        placeholderTips: '',
        visible: false,
      };
    },
    methods: {
      show() {
        this.visible = true;
        this.placeholderTips = this.inputPlaceholder;
      },
      btnConfirm() {
        const _this = this;
        if (this.inputValue === '') {
          this.$message({
            message: _this.placeholderTips,
            type: 'error'
          });
        } else {
          this.$emit('confirm', this.inputValue);
          this.colse();
        }
      },
      colse() {
        //关闭键盘
        // this.$emit('close', false);
        this.visible = false;
      },
    },
  };
</script>
